package designpattern.proxy.impl;

import net.sf.cglib.proxy.MethodInterceptor;
import net.sf.cglib.proxy.MethodProxy;
import org.apache.log4j.Logger;

import java.lang.reflect.Method;

/**
 * @author 吴阳基
 * @datetime 2024/1/6 10:03
 */
public class IntermediaryMethodInterceptor implements MethodInterceptor {
    private Logger logger = Logger.getLogger(IntermediaryMethodInterceptor.class);
    @Override
    public Object intercept(Object o, Method method, Object[] objects, MethodProxy methodProxy) throws Throwable {
        before();
        Object feedback =  methodProxy.invokeSuper(o, objects);
        after();
        return "看房记录：买家反馈" + feedback;
    } private void before(){
        logger.info("买家进入看房记录");
    }
    private void after(){
        logger.info("买家离开看房记录");
    }
}
